<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:pe="http://primefaces.org/ui/extensions">
    <h:head>
        <title>#{bundle.savwd}</title>
        <link href="./resources/css/default.css" rel="stylesheet" type="text/css" />
    </h:head>
    <h:body>
        <ui:composition>
            <h:form prependId="false">
               <script type="text/javascript">  
                    
                   var doInitForm=false;
                   var tofocus;
                   
                   function changeFocus(nextfcs) {tofocus=nextfcs;}
                   function setDoInitForm(st) {doInitForm=st;}
                   
                   function focusState(xhr, status, args) {  
                       if(args.validationFailed || !args.success) {}
                       else document.getElementById(tofocus).focus();
                       return false;
                   }
                   
                   function handleCompleteSaving(xhr, status, args) {  
                        if(args.validationFailed || !args.success) {
                            
                        }else 
                            setTimeout(function() {
                                if (doInitForm==true) btnNewSavwdgl.jq.click();  
                            }, 3000);
                    }
                    
                    function customRK(e, id, nextfcs) {
                      var code = (e.keyCode ? e.keyCode : e.which);
                       if(code==13) {
                            
                            if (id=="savwdGLSavingNo") {
                               rcsavwdglGetSaving();
                               tofocus=nextfcs;
                            } 
                            
                            e.preventDefault ? e.preventDefault() : e.returnValue = false;
                            e.stopPropagation();
                       }
                    }
                </script>  
                <p:outputPanel autoUpdate="true">
                <p:toolbar >
                    <p:toolbarGroup align="left">
                        <p:commandButton value="#{bundle.btnNew}" icon="ui-icon-document" widgetVar="btnNewSavwdgl"  oncomplete="setDoInitForm(false);" 
                                         rendered="#{menuBean.cekButtonAccess(107,'INS;')}"
                                         action="#{savwdglBean.newData()}" process="@this" update="displaySavwdgl">
                            <pe:resetEditableValues for="displaySavwdgl"/>  
                        </p:commandButton> 
                                                    
                        <p:commandButton id="submitSavwdGL" value="#{bundle.btnSave}" icon="ui-icon-disk"
                                         action="#{savwdglBean.trySave()}" oncomplete="setDoInitForm(true); handleCompleteSaving(xhr, status, args);" 
                                         rendered="#{menuBean.cekButtonAccess(107,'INS;')}"
                                         update="displaySavwdgl" disabled="#{!savwdglBean.editMode}" >
                        </p:commandButton>

                    </p:toolbarGroup>
                    <p:toolbarGroup align="right">
                        <p:commandButton id="doNothingSavwdgl" type="button" value="" style="width: 0px; height: 0px;"/> 
                        <p:defaultCommand target="#{savwdglBean.defaultButton}"/> 
                    </p:toolbarGroup>
                </p:toolbar>
                </p:outputPanel>
                                
                <p:remoteCommand name="rcsavwdglGetSaving" actionListener="#{savwdglBean.getSavingSrc('null')}" 
                                 update="hideSavwdglSavaccntId savwdglsaldoawal savwdglCustInfo" process="savwdGLSavingNo @this" 
                                  oncomplete="focusState(xhr, status, args);"/>
                                
                <!-- LOOK UP saving -->
                <p:dialog header="#{bundle.Select} #{bundle.accountNo}" widgetVar="dlgSavwdglLookupSav" closable="true" dynamic="true" >
                    <p:ajax listener="#{savwdglBean.handleCloseLookup}" />
                    <h:panelGrid id="displaySavwdglLookup" rendered="#{savwdglBean.showLookup==true}">
                        <ui:include src="../saving/searchSaving.xhtml" >
                            <ui:param name="lookupSavComponenId" value="savwdgl" />
                        </ui:include> 

                        <h:panelGrid cellpadding="0" styleClass="pComBtnSTDR" >
                            <f:facet name="footer">
                                <p:commandButton value="#{bundle.btnOK}" icon="ui-icon-disk" immediate="true" 
                                                process="@this" update="savwdGLSavingNo, hideSavwdglSavaccntId, savwdglsaldoawal"
                                                action="#{savwdglBean.getSavingSrc(searchSavingBean.selectedData.accountNo)}" 
                                                oncomplete="dlgSavwdglLookupSav.hide(); focusState(xhr, status, args);" />

                                <p:commandButton value="#{bundle.btnClose}" oncomplete="dlgSavwdglLookupSav.hide()" immediate="true" icon="ui-icon-document" process="@this" />
                            </f:facet>
                        </h:panelGrid>
                    </h:panelGrid>
                </p:dialog>
                
                <h:panelGrid id="displaySavwdgl" styleClass="addELIT" cellpadding="0">
                    <h:panelGrid columns="2" cellpadding="1" rowClasses="panelGridId" border="0">
                        <p:panel header="#{bundle.wdLedgend}">
                            <h:panelGrid columns="3" cellpadding="0" cellspacing="10">
                                <h:outputLabel value= "#{bundle.date}" /><h:outputLabel value=":" />
                                <h:outputText value="#{savwdglBean.savwd.transDate}" />

                                <h:outputLabel value= "#{bundle.savingNo}" /><h:outputLabel value=":" />
                                <h:panelGrid columns="2" cellpadding="0" cellspacing="0">                                
                                    <p:inputText value="#{savwdglBean.savwd.saving.accountNo}" style="width: 122px;"
                                        onkeydown="customRK(event, 'savwdGLSavingNo', '#{utilityBean.findClientId('savwdglAmount')}')" label="#{bundle.savingNo}" 
                                        id="savwdGLSavingNo" required="true" disabled="#{!savwdglBean.authorized}"
                                        requiredMessage="#{bundle.savingNo} #{bundle.requiredInput}">
                                        <p:ajax event="keyup" update="msgsavwdGLSavingNo" process="@this"/>
                                    </p:inputText>
                                    
                                    <p:commandButton icon="ui-icon-search" iconPos="center" styleClass="btnSmall"
                                                     update="displaySavwdglLookup" onclick="changeFocus('#{utilityBean.findClientId('savwdglAmount')}');"
                                                     process="@this" immediate="true" oncomplete="dlgSavwdglLookupSav.show();" disabled="#{!savwdglBean.editMode}">
                                        <f:setPropertyActionListener target="#{savwdglBean.showLookup}" value="#{true}" />
                                    </p:commandButton>
                                    
                                    <p:message id="msgsavwdGLSavingNo" for="savwdGLSavingNo" display="icon" />
                                </h:panelGrid>         
                                
                                <h:outputLabel value= "#{bundle.saldoAwal}" /><h:outputLabel value=":"/>
                                <h:outputLabel value="#{savwdglBean.saldoAwal}" styleClass="numPos" id="savwdglsaldoawal" style="padding: 0 152px 0 0;">
                                    <f:convertNumber groupingUsed="true" />
                                </h:outputLabel>
                                
                                <h:outputLabel value= "#{bundle.amount}" /><h:outputLabel value=":" />
                                <h:panelGrid columns="2" cellpadding="0" cellspacing="0">
                                    <pe:inputNumber decimalSeparator="." thousandSeparator="," maxValue="999999999999999.99" minValue="0" 
                                        styleClass="money" style="width: 150px;" 
                                        value="#{savwdglBean.savwd.amount}" label="#{bundle.amount}"
                                        id="savwdglAmount" required="true" disabled="#{!savwdglBean.authorized}"
                                        requiredMessage="#{bundle.amount} #{bundle.requiredInput}">
                                        <p:ajax event="keyup" update="msgsavwdglAmount savwdglBalance" listener="#{savwdglBean.calcSaldoAhir()}" process="@this" partialSubmit="false"/>
                                    </pe:inputNumber >
                                    <p:message id="msgsavwdglAmount" for="savwdglAmount" display="icon" />
                                </h:panelGrid>
                                
                                <h:outputLabel value= "#{bundle.balance}" /><h:outputLabel value=":"/>
                                <h:outputLabel value="#{savwdglBean.saldoAkhir}" styleClass="numPos" id="savwdglBalance" style="padding: 0 152px 0 0;">
                                     <f:convertNumber groupingUsed="true" />
                                </h:outputLabel>
                                                 
                                <h:outputLabel style="padding: 0 15px 0 0;" value= "#{bundle.glaccnt}" /><h:outputLabel value=":"/>
                                <h:panelGrid columns="2" cellpadding="0" cellspacing="0" >
                                    <p:selectOneMenu value="#{savwdglBean.savwd.savtrxglId}" id="savwdtrxglId" label="#{bundle.glaccnt}" 
                                                     requiredMessage="#{bundle.glaccnt} #{bundle.requiredInput}" style="width: 300px;"
                                                     required="true" disabled="#{!savwdglBean.authorized}">
                                        <f:selectItems value="#{savwdglBean.availableGL}" var="gl" itemValue="#{gl.savtrxglId}" itemLabel="#{gl.glaccount.accountName}"/>
                                        <p:ajax listener="#{savwdglBean.handleProdChange}" update="msgsavwdtrxglId"  process="@this" />  
                                    </p:selectOneMenu>
                                    <p:message id="msgsavwdtrxglId" for="savwdtrxglId" display="icon" />
                                </h:panelGrid>
                                
                                <h:inputHidden value="#{savwdglBean.savwd.saving.savaccntId}" id="hideSavwdglSavaccntId"
                                    required="true" requiredMessage="#{bundle.savingNo} #{bundle.requiredInput}" />
                                <h:inputHidden />
                            </h:panelGrid>
                        </p:panel>

                        <p:outputPanel autoUpdate="true" id="savwdglCustInfo">
                        <p:panel header="#{bundle.cusledgen}">
                            <h:panelGrid columns="3" style="width: 100%" cellpadding="0" cellspacing="10">
                                <h:outputLabel value= "#{bundle.cif}" /><h:outputLabel value=":" />
                                <h:outputText value="#{savwdglBean.savwd.saving.customer.cif}" />

                                <h:outputLabel value= "#{bundle.globalName}" /><h:outputLabel value=":" />
                                <h:outputText value="#{savwdglBean.savwd.saving.customer.customerName}" />

                                <h:outputLabel value= "#{bundle.aliasName}" /><h:outputLabel value=":" />
                                <h:outputText rendered="true" value="#{savwdglBean.savwd.saving.customer.aliasName}" />

                                <h:outputLabel value= "#{bundle.npwp}" /><h:outputLabel value=":" />
                                <h:outputText value="#{savwdglBean.savwd.saving.customer.npwp}" />

                                <h:outputLabel style="padding: 0 15px 0 0;" value= "#{bundle.officePhone}" /><h:outputLabel value=":" />
                                <h:outputText value="#{savwdglBean.savwd.saving.customer.cusper.officePhone}"/>

                                <h:outputLabel value= "#{bundle.phone}" /><h:outputLabel value=":" />
                                <h:outputText value="#{savwdglBean.savwd.saving.customer.phone}"/>

                                <h:outputLabel value= "#{bundle.mobilePhone}" /><h:outputLabel value=":" />
                                <h:outputText value="#{savwdglBean.savwd.saving.customer.mobilePhone}"/>
                                
                                <h:outputLabel value= "#{bundle.specimen}" /><h:outputLabel value=":"/>
                                <p:graphicImage  value="/upload/personal/#{savwdglBean.savwd.saving.customer.specimen}" />
                                
                            </h:panelGrid>
                        </p:panel>
                        </p:outputPanel>
                    </h:panelGrid>
                </h:panelGrid>
            </h:form>
        </ui:composition>
    </h:body>
</html>